<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>float高度塌陷问题</title>
    <style>
        div {
            /* padding: 0; */
            margin: 0;
        }

        .box {
            width: 400px;
            height: 400px;
            background-color: orange;
        }

        .item {
            text-align: center;
            float: left;
            width: 70px;
            height: 100px;
            background-color: blue;
            margin-left: 10px;
        }

        .it {
            height: 50px;
            background-color: red;
            color: #fff;
        }

        .why::after {
            content: "";
            display: block;
            clear: both;
        }
    </style>
</head>

<body>
    <div class="box">
        <div class="why">
            <div class="item">1</div>
            <div class="item">2</div>
            <div class="item">3</div>
            <div class="item">4</div>
            <div class="item why">5</div>
        </div>
        <div class="it"></div>
    </div>
</body>

</html>